package com.yujinglin.maxmin;


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.IntWritable;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class MaxMinDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {

        Configuration conf=new Configuration();
        Job job = Job.getInstance(conf,"MyMaxValue");

        job.setJarByClass(MaxMinDriver.class);

        job.setMapperClass(MaxMinMapper.class);
        job.setNumReduceTasks(1);
        job.setReducerClass(MaxMinReducer.class);

        job.setMapOutputKeyClass(IntWritable.class);
        job.setMapOutputValueClass(DoubleWritable.class);

        // 设置Reducer输出的key和value类型
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(DoubleWritable.class);

        FileInputFormat.setInputPaths(job,new Path("/data/flights.csv"));
        FileOutputFormat.setOutputPath(job,new Path("/home/niit/Output3"));

//        FileInputFormat.setInputPaths(job,new Path("C:/Users/hanyiyang/Desktop/flights.csv"));
//        FileOutputFormat.setOutputPath(job,new Path("src/main/java/input/outputYu/Output3"));

        job.waitForCompletion(true);
    }
}
